package com.liao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liao.bean.OrderCount;
import com.liao.bean.VisitList;
import com.liao.bean.result.Msg;
import com.liao.bean.result.PageResult;
import com.liao.dao.OrderCountDao;
import com.liao.service.OrderCountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderCountServiceImpl implements OrderCountService {

    @Autowired
    private OrderCountDao orderCountDao;

    @Override
    public PageResult<OrderCount> queryOrderCountListByPage(Integer currentPage, Integer pageSize, String orderId) throws Exception {

        PageHelper.startPage(currentPage,pageSize);


        List<OrderCount> orderCountList=orderCountDao.selectOrderCountListByPage(orderId);
        PageInfo<OrderCount> pageInfo=new PageInfo<>(orderCountList);

        return new PageResult<>(0, Msg.MODULE_QUERY_SUCCESS,pageInfo.getTotal(),pageInfo.getList());
    }

    @Override
    public void deleteOrderCountById(String ocid) throws Exception {
        orderCountDao.deleteOrderCountById(ocid);
    }

    @Override
    public void addOrderCount(String ocid, String orderId, String orderMoney, String orderPMoney) throws Exception {
        OrderCount orderCount=new OrderCount();
        orderCount.setOcid(ocid);
        orderCount.setOrderId(orderId);
        orderCount.setOrderMoney(orderMoney);
        orderCount.setOrderPMoney(orderPMoney);

        orderCountDao.addOrderCount(orderCount);
    }

    @Override
    public void updateOrderCount(String ocid, String orderId, String orderMoney, String orderPMoney) throws Exception {
        OrderCount orderCount=new OrderCount();
        orderCount.setOcid(ocid);
        orderCount.setOrderId(orderId);
        orderCount.setOrderMoney(orderMoney);
        orderCount.setOrderPMoney(orderPMoney);

        orderCountDao.updateOrderCount(orderCount);
    }
}
